﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace QlrrPrintService.Common.Command
{
    /// <summary>
    /// 绘制方框
    /// </summary>
    public class Box:IToTSPLCommand
    {
        /// <summary>
        /// 左侧左边，单位dot
        /// </summary>
        private PrintLocation _leftPrintLocation=new PrintLocation();

        /// <summary>
        /// 右下角坐标
        /// </summary>
        private PrintLocation _rightPrintLocation=new PrintLocation();

        private int _thickness;

        public int Thickness
        {
            get { return _thickness; }
            set { _thickness = value; }
        }

     

        public PrintLocation LeftPrintLocation
        {
            get { return _leftPrintLocation; }
            set { _leftPrintLocation = value; }
        }

        public PrintLocation RightPrintLocation
        {
            get { return _rightPrintLocation; }
            set { _rightPrintLocation = value; }
        }

        #region IToTSPLCommand 成员

        public byte[] ToTSPLCommandByte(int mm_to_dot)
        {
            return Util.GetEncodingBytes(ToTSPLCommandAscii(mm_to_dot));
        }

        public string ToTSPLCommandAscii(int mm_to_dot)
        {
            return string.Format("BOX {0},{1},{2},{3},{4}{5}",
                _leftPrintLocation.X * mm_to_dot,
                _leftPrintLocation.Y * mm_to_dot,
                _rightPrintLocation.X * mm_to_dot,
                _rightPrintLocation.Y * mm_to_dot,
                _thickness * mm_to_dot, Common.TSPL_END);
        }

        #endregion
    }
}
